package org.zcl.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.zcl.entity.User;

import javax.servlet.http.HttpServletRequest;

/**
 * .
 *
 * @author zhuchenglin
 * @since 2024/7/4 20:55
 */
@RestController
@RequestMapping("/simple")
public class SimpleController {

    @GetMapping("/get/{id}")
    public Integer getString(@PathVariable("id") Integer id, HttpServletRequest request) {
        String remoteAddr = request.getRemoteAddr();
        int remotePort = request.getRemotePort();
        System.out.println("remoteAddr = " + remoteAddr);
        System.out.println("remotePort = " + remotePort);
        return id;
    }

    @GetMapping("/getById/{id}")
    User getById(@PathVariable(value = "id") Long id) {
        // openfeign-test
        return User.builder().id(id).name("zcl").age(29).build();
    }
}
